package cn.zhejianglao.oss.common;

import lombok.Data;

@Data
public class Response {
    private String message;
    private int code;
    private Object data;

    private Response() {}



    private Response(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private Response(int code) {
        this.code = code;
    }

    private Response(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    /**
     * Default ok response
     * @return {200, "success"}
     */
    public static Response ok() {
        return new Response(200, "success");
    }

    public static Response ok(Object data) {
        return new Response(200, "success", data);
    }

    public static Response fail(int code) {
        return new Response(code);
    }

    public static Response fail(String errorMessage) {
        return new Response(500, errorMessage);
    }
    public static Response fail(int code, String errorMessage) {
        return new Response(code, errorMessage);
    }

}
